import request from '@/utils/request'
import qs from 'qs'

export function getAction(url, parameter) {
  return request({
    url: url,
    method: 'get',
    params: parameter
  })
}

// 获取图片验证码 —— 文件流
export function getBlobAction(url, parameter) {
  return request({
    url: url,
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}

export function postAction(url, parameter) {
  return request({
    url: url,
    method: 'post',
    data: parameter
  })
}

export function postFormAction(url, parameter) {
  return request({
    url: url,
    method: 'post',
    data: qs.stringify(parameter)
  })
}

export function postFormAction2(url, data) {
  return request({
    url: url,
    method: 'post',
    data: qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

export function postFormAction3(url, data) {
  return request({
    url: url,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 文件上传
export function uploadAction(url, parameter) {
  return request({
    url: url,
    data: parameter,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data' // 文件上传
    }
  })
}

// excel导出
export function downFile(url, data) {
  return request({
    url: url,
    method: 'get',
    params: data,
    responseType: 'blob'
  })
}
export function downFilePost(url, data) {
  return request({
    url: url,
    method: 'post',
    responseType: 'blob'
  })
}
